
import axios from "axios";
import {showErrMsg} from "@/utils/message"


const instance = axios.create(
    {
        baseURL : '/console',
        timeout: 50000,
    }
);

instance.interceptors.request.use((config) => {
    return config;
},(err) => Promise.reject(err))



instance.interceptors.response.use((response) =>{
    const data = response.data as IResponse<any>
    if (data.errno != 0){
        // alert(data.errmsg)
        showErrMsg(data.errmsg)
    }
    // alert(data.data)
    return data.data;
},(err)  => {
    console.log(err);
    
    showErrMsg(err.message)
})



export default instance;